@extends('back_end.layouts.default_info')

{{-- Web site Title --}}
@section('title')
{{{ Lang::get('general.back_end.staff') }}} @if (isset($entry)){{{Lang::get('general.edit') }}}@else{{{Lang::get('general.create') }}}@endif :: @parent
@stop
@section('content_header')
{{{ Lang::get('general.back_end.staff') }}} @if (isset($entry)){{{Lang::get('general.edit') }}}@else{{{Lang::get('general.create') }}}@endif
@stop
{{-- breadcrumb --}}
@section('breadcrumb')
<li><a href="#"><i class="fa fa-dashboard"></i> {{{ Lang::get('general.back_end.home') }}}</a></li>
<li class="active">{{{ Lang::get('general.back_end.staff') }}} @if (isset($entry)){{{Lang::get('general.edit') }}}@else{{{Lang::get('general.create') }}}@endif</li>
@stop

{{-- Content --}}
@section('content')
<div class="box box-primary">

  {{-- Create Form --}}
    @if(isset($entry))
    {{ Form::open(array('action' => array('BackStaffController@doUpdate',$entry->id))) }}
    @else
    {{ Form::open(array('action' => 'BackStaffController@doCreate')) }}
    @endif
    <div class="box-body">
      <!-- Tabs -->
      <ul class="nav nav-tabs">
        <li class="active"><a href="#tab-general" data-toggle="tab">基本信息</a></li>
      </ul>
      <!-- ./ tabs -->


      <!-- Tabs Content -->
      <div class="tab-content">
        <!-- General tab -->
        <div class="tab-pane active" id="tab-general">
          <br/>
            {{ $tab_index = 1 ? '' : '' }}
            {{ $tab_index++ }}
            {{ Form::textGroup('username',  '用户名',   Input::old('username', isset($entry) ? $entry->user->username : ''),   $errors, $tab_index++, true) }}

            {{ Form::textGroup('name',      '用户姓名', Input::old('name', isset($entry) ? $entry->name : ''),            $errors, $tab_index++, true) }}

            {{ Form::textGroup('email',     'Email',  Input::old('email', isset($entry) ? $entry->user->email : null),         $errors, $tab_index++, true) }}

            {{ Form::passwordGroup('password',  '密码', $errors, $tab_index++, true) }}

            {{ Form::passwordGroup('password_confirmation','密码确认', $errors, $tab_index++, true) }}

            {{ Form::selectGroup('confirmed','激活账号?', array('1'=>Lang::get('general.yes'),'0'=>Lang::get('general.no') ), Input::old('confirmed', (isset($entry)&&$entry->user->confirmed) ? 1 : 0 ), $errors, $tab_index++, true) }}

          <!-- Groups -->
          <div class="form-group row col-lg-4 col-md-6 col-xs-12 {{{ $errors->has('roles') ? 'has-error' : '' }}}">
            {{ Form::label('roles', '角色') }}
            <div class="col-lg-12 col-md-12 col-xs-12">
              <select class="form-control" name="roles[]" id="roles[]" multiple tabindex="{{ $tab_index++ }}">
                @foreach (Role::select('id','display_name')->get() as $role)
                @if (!isset($entry))
                <option value="{{{ $role->id }}}"{{{ ( in_array($role->id, Input::old('roles', array())) ? ' selected="selected"' : '') }}}>{{{ $role->display_name }}}</option>
                @else
                <option value="{{{ $role->id }}}"{{{ ( array_search($role->id, $entry->currentRoleIds()) !== false && array_search($role->id, $entry->currentRoleIds()) >= 0 ? ' selected="selected"' : '') }}}>{{{ $role->display_name }}}</option>
                @endif
                @endforeach
              </select>

						<span class="help-block">
							为用户选择一个角色，将为用户赋予该角色的权限.
						</span>
            </div>
          </div>
          <!-- ./ groups -->
        </div>
        <!-- ./ general tab -->

      </div>
      <!-- ./ tabs content -->

      {{ Form::submitButtonGroup('BackStaffController@getIndex', (Auth::user()->can('create_staff')||Auth::user()->can('update_staff')) , $tab_index) }}

      <!-- ./ form actions -->
    </div>
    {{ Form::close() }}
</div>
@stop


{{-- Scripts --}}
@section('scripts')
<script type="text/javascript">


</script>
@stop